MYDB:=mydb

MYDB_BASEDIR:=$(BASEDIR)/$(MYDB)

MYDB_CC:=g++
MYDB_LD:=g++

MYDB_MODULES_DEPENDENCIES:=myfile mythread

MYDB_INCFLAGS:=-I$(MYDB_BASEDIR)/inc -I$(BASEDIR)/common/inc -Imysql/$(SYSTEM)/inc $(patsubst %, -I$(BASEDIR)/%/inc, $(MYDB_MODULES_DEPENDENCIES))

ifeq ($(SYSTEM), MINGW32_NT-5.1)
MYDB_DEBUG_CFLAGS:=-g -Wall -W -pedantic -Woverloaded-virtual -D_REENTRANT -DDEBUG $(MYDB_INCFLAGS)
MYDB_DEBUG_LDFLAG:=
MYDB_DEBUG_LIBS:=

MYDB_RELEASE_CFLAGS:=-Wall -W -pedantic -Woverloaded-virtual -D_REENTRANT -DRELEASE $(MYDB_INCFLAGS)
MYDB_RELEASE_LDFLAG:=
MYDB_RELEASE_LIBS:=

MYDB_SCRAMBLED_CFLAGS:=-Wall -W -pedantic -Woverloaded-virtual -D_REENTRANT -DRELEASE -DSCRAMBLE_SYMBOLS $(MYDB_INCFLAGS)
MYDB_SCRAMBLED_LDFLAG:=
MYDB_SCRAMBLED_LIBS:=

endif

ifeq ($(SYSTEM), Linux)
MYDB_DEBUG_CFLAGS:=-g -Wall -W -pedantic -Woverloaded-virtual -D_REENTRANT -DDEBUG $(MYDB_INCFLAGS)
MYDB_DEBUG_LDFLAG:=
MYDB_DEBUG_LIBS:=

MYDB_RELEASE_CFLAGS:=-Wall -W -pedantic -Woverloaded-virtual -D_REENTRANT -DRELEASE $(MYDB_INCFLAGS)
MYDB_RELEASE_LDFLAG:=
MYDB_RELEASE_LIBS:=

MYDB_SCRAMBLED_CFLAGS:=-Wall -W -pedantic -Woverloaded-virtual -D_REENTRANT -DRELEASE -DSCRAMBLE_SYMBOLS $(MYDB_INCFLAGS)
MYDB_SCRAMBLED_LDFLAG:=
MYDB_SCRAMBLED_LIBS:=

endif

MYDB_SRC:=$(shell ls 2>&1 $(MYDB_BASEDIR)/src/*.cpp)

TMP_MYDB_OBJ:= $(patsubst %.cpp,%.o,$(filter %.cpp,$(MYDB_SRC)))
TMP_MYDB_DEP:= $(patsubst %.cpp,%.d,$(filter %.cpp,$(MYDB_SRC)))

SRC+=$(MYDB_SRC)

MYDB_DEBUG_OBJS=$(shell echo $(TMP_MYDB_OBJ) | sed -e 's@src@obj/debug@g' )
MYDB_RELEASE_OBJS+=$(shell echo $(TMP_MYDB_OBJ) | sed -e 's@src@obj/release@g' )
MYDB_SCRAMBLED_OBJS+=$(shell echo $(TMP_MYDB_OBJ) | sed -e 's@src@obj/scrambled@g' )

DEBUG_OBJS+=$(MYDB_DEBUG_OBJS)
RELEASE_OBJS+=$(MYDB_RELEASE_OBJS)
SCRAMBLED_OBJS+=$(MYDB_SCRAMBLED_OBJS)

# Dependencies are release independant.
DEPS+=$(shell echo $(TMP_MYDB_DEP) | sed -e 's@src@dep@g' )

DEBUG_MYDB_ARCHIVE:=$(BASEDIR)/lib/debug/$(MYDB).a
RELEASE_MYDB_ARCHIVE:=$(BASEDIR)/lib/release/$(MYDB).a
SCRAMBLED_MYDB_ARCHIVE:=$(BASEDIR)/lib/scrambled/$(MYDB).a

DEBUG_ARCHIVES+=$(DEBUG_MYDB_ARCHIVE)
RELEASE_ARCHIVES+=$(RELEASE_MYDB_ARCHIVE)
SCRAMBLED_ARCHIVES+=$(SCRAMBLED_MYDB_ARCHIVE)
